﻿@using BlazorBlogs.Data;
@inherits OwningComponentBase<GeneralSettingsService>

<AuthorizeView>
    <Authorized>
        <a href="Identity/Account/Manage">Hello, @context.User.Identity.Name!</a>
        <form method="post" action="Identity/Account/LogOut">
            <button type="submit" class="nav-link btn btn-link">Log out</button>
        </form>
    </Authorized>
    <NotAuthorized>
        @if (AllowRegistration)
        {
            <a href="Identity/Account/Register">Register</a>
        }
        <a href="Identity/Account/Login">Log in</a>
    </NotAuthorized>
</AuthorizeView>
@code {
    bool AllowRegistration = false;

    protected override async Task OnInitializedAsync()
    {
        var objGeneralSettings = await @Service.GetGeneralSettingsAsync();
        AllowRegistration = objGeneralSettings.AllowRegistration;
    }
}